#include "stm32f10x.h"
#include "tim.h"
/* TIM2, TIM8 configuration */
void TIM_Configuration(void)
{
	/* Time base configuration */
	TIM_TimeBaseInitTypeDef   TIM_TimeBaseStructure;
	TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
	
	TIM_TimeBaseStructure.TIM_Period = 1000;					// 9000 = 8 kHz sampling frequency
	TIM_TimeBaseStructure.TIM_Prescaler = 0;
	TIM_TimeBaseStructure.TIM_ClockDivision = 0;
	TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Down;
	TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
	TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
	
	/* TIM2 enable counter */
	TIM_Cmd(TIM2, ENABLE);	
}
